package com.coocaa.optimizer.bugreport;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.DropBoxManager;
import android.util.Log;

/**
 * Created by lu on 17-3-31.
 */

public class BugReport implements Runnable {
    private static DropBoxManager dbm = null;
    private Intent intent = null;

    BugReport(Context context, Intent intent) {
        this.intent = intent;
        if (dbm == null)
            dbm = (DropBoxManager) context.getSystemService(Context.DROPBOX_SERVICE);
    }

    @Override
    public void run() {
        Log.d("DBR", "intent:" + intent.toString());
        Bundle bundle = intent.getExtras();

        String tag = bundle.getString("tag");
        long time = bundle.getLong("time");
        Log.d("DBR", "tag:" + tag + " time:" + time);
        DropBoxManager.Entry entry = dbm.getNextEntry(tag, time - 100);
        String error = entry.getText(1024 * 64);
        Log.d("DBR", error);
        entry.close();
    }
}
